package com.zhongxi.guoyuan.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.telephony.TelephonyManager;

import com.zhongxi.guoyuan.application.MyApplication;

/**
 * Created by Administrator on 2016/11/14.
 */

public class DeviceUtils {
    /**
     * 获取设备的唯一标识符
     *
     * @param myApplication
     * @return
     */
    @SuppressLint("MissingPermission")
    public static String getDeviceUUID(MyApplication myApplication) {

        TelephonyManager telephonyManager;
        telephonyManager = (TelephonyManager) myApplication.getSystemService(Context.TELEPHONY_SERVICE);
        String uuid = telephonyManager.getDeviceId();
        return uuid;
    }

    public static String getSimOperatorName(MyApplication myApplication) {

        TelephonyManager telephonyManager;
        telephonyManager = (TelephonyManager) myApplication.getSystemService(Context.TELEPHONY_SERVICE);
        String operName = telephonyManager.getSimOperatorName();
        return operName;
    }


    /**
     *  * 获取手机卡类型，移动、联通、电信
     */
    public static String getMobileType(Context context) {
        String type = "";
        TelephonyManager iPhoneManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String iNumeric = iPhoneManager.getSimOperator();
        if (iNumeric.length() > 0) {
            if (iNumeric.equals("46000") || iNumeric.equals("46002")) {
                type = "中国移动";
            } else if (iNumeric.equals("46001")) {
                type = "中国联通";
            } else if (iNumeric.equals("46003")) {
                type = "中国电信";
            }
        }
        return type;
    }

}
